package com.arvato.right.controller;

import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.arvato.minipro.bean.bean_dto.common.PageData;
import com.arvato.minipro.bean.bean_dto.common.Query;
import com.arvato.minipro.bean.bean_dto.common.Result;
import com.arvato.minipro.controller.BaseController;
import com.arvato.right.bean.bean_do.WxworkRightPassDo;
import com.arvato.right.service.WxworkRightPassService;
@Controller
@RequestMapping("/admin/right/pass")
public class RightPassController extends BaseController{
	
	@Autowired
	private WxworkRightPassService wxworkRightPassService;

	/**
	 * 获取免检1资源列表
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/list", method = {RequestMethod.POST})
	public PageData listPass(@RequestParam Map<String, Object> param){
		Query query = new Query(param);
		PageData pageData = wxworkRightPassService.listPassByQuery(query, query.getPageNum(), query.getPageSize());
		return pageData;
	}
	
	
	/**
	 * 新增免检资源
	 * @param resourcDo
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/insert", method = {RequestMethod.POST})
	public Object insert(WxworkRightPassDo passDo){
		try {
			int row = wxworkRightPassService.insert(passDo);
			if(row == 1){
				return Result.success();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Result.fail("新增失败");
	}
	
	/**
	 * 删除资源
	 * @param Pass
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/delete", method = {RequestMethod.POST})
	public Result delete(String id){
		try {
			int row = wxworkRightPassService.delete(id);
			if(row == 1){
				return Result.success("删除成功");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Result.fail("删除失败");
	}
	
}
